package praca.gra;

import java.util.List;

import praca.framework.TextureGL;
import praca.framework.Vector;
import praca.framework.Vertices;
import praca.interfejsy.Game;
import praca.interfejsy.Screen;
import praca.interfejsy.Texture;
import praca.interfejsy.TouchEvent;
import android.util.Log;

public class VectorScreen extends Screen{

	Vertices vert;
	Vector touchPos;
	Vector trianglePos;
	TouchEvent ev;
	float angle = 0;
	Texture texture;
	
	public VectorScreen(Game game) {
		super(game);
		vert = new Vertices(50,200,false);
		trianglePos = new Vector(200, 200);
		touchPos = new Vector(0,0);
	}

	@Override
	public void update(float deltaTime) {
		g.clearTransformations();
		if(!in.getTouchEvents().isEmpty()){
			ev = in.getTouchEvents().remove(0);
			if(ev.getType() == TouchEvent.TOUCH_UP){
				touchPos.setXY(ev.getX(), ev.getY());
				angle = 90 + touchPos.sub(trianglePos).angle();
				//Log.d("touch", "touch x: "+ev.getX()+" ,y: "+ev.getY());
			}
		}
		
		g.drawColor(0, 0.2f, 1);
		g.moveTexture(200, 200);//od konca transformacje
		g.rotateTexture(angle);
		g.drawRect(vert);
	}



	@Override
	public void pause() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void resume() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub
		
	}


}
